package com.yixin.hospital.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yixin.hospital.common.ApiResult;
import com.yixin.hospital.entity.domain.PatientSource;
import com.yixin.hospital.entity.dto.req.patientsource.PatientSourceAddReqDTO;
import com.yixin.hospital.entity.dto.req.patientsource.PatientSourceEditReqDTO;
import com.yixin.hospital.service.PatientSourceService;
import com.yixin.hospital.mapper.PatientSourceMapper;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

/**
* @author Administrator
* @description 针对表【patient_source(患者来源表)】的数据库操作Service实现
* @createDate 2024-04-25 15:41:24
*/
@Service
public class PatientSourceServiceImpl extends ServiceImpl<PatientSourceMapper, PatientSource>
    implements PatientSourceService{

    @Override
    public ApiResult add(PatientSourceAddReqDTO patientSourceAddReqDTO, String userName) {
        PatientSource patientSource = new PatientSource();
        BeanUtils.copyProperties(patientSourceAddReqDTO, patientSource);
        patientSource.setCreatedBy(userName);
        patientSource.setUpdatedBy(userName);
        this.save(patientSource);
        return ApiResult.success();
    }

    @Override
    public ApiResult edit(PatientSourceEditReqDTO patientSourceEditReqDTO, String userName) {
        PatientSource patientSource = new PatientSource();
        BeanUtils.copyProperties(patientSourceEditReqDTO, patientSource);
        patientSource.setUpdatedBy(userName);
        this.updateById(patientSource);
        return ApiResult.success();
    }
}




